//
//  LRMainMenuLayer.m
//  lineRunner_cocos2d
//
//  Created by chen jingsen on 13-1-17.
//  Copyright 2013年 __MyCompanyName__. All rights reserved.
//

#import "LRMainMenuLayer.h"


@implementation LRMainMenuLayer

- (id)init
{
    if (self = [super init]) {
        [self LR_CreateMenu];
    }
    return self;
}

- (void)LR_CreateMenu
{
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    
    LRCCMenuItem* options = [LRCCMenuItem itemWithNormalImage:@"lr_menu_options.png" selectedImage:@"lr_menu_options.png"];
    LRCCMenuItem* tutorial = [LRCCMenuItem itemWithNormalImage:@"lr_menu_tutorial.png" selectedImage:@"lr_menu_tutorial.png"];
    LRCCMenuItem* start = [LRCCMenuItem itemWithNormalImage:@"lr_menu_start.png" selectedImage:@"lr_menu_start.png"];
//    LRCCMenuItem* menuImage = [LRCCMenuItem itemWithNormalImage:@"lr_menu_options.png" selectedImage:@"lr_menu_options.png"];
    CCMenu *menu = [CCMenu menuWithItems:start,options,tutorial, nil];
    menu.position = CGPointMake(0, 0);
    
    LRCCMenuItem* menuItem;
    int i = 0;
    CCARRAY_FOREACH([menu children], menuItem){
        CGPoint mentPoint = menuItem.position;
        int offset = winSize.height/2;

        CGPoint startPoint = ccp(mentPoint.x, offset);
        CGPoint endPoint = ccp(mentPoint.x, mentPoint.y - offset + i*50  - 30);
        if (i == 0) {
            
            endPoint = ccp(mentPoint.x, mentPoint.y - offset - 120);
        }
        menuItem.position = startPoint;
        [menuItem runAction:[CCEaseElasticOut actionWithAction:[CCMoveBy actionWithDuration:2.0f position:endPoint] period:0.35f]];
        i ++;
    }
    [self addChild:menu];
}


- (void)dealloc
{
    [super dealloc];
}
@end
